﻿#region Librerias

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Net;
using ESF.General.ClickOnce;
using ESF.General;
using ESF.SFT.FileUploader.SharedResources;
using ESF.WinForms;
using ESF.WinForms.Elements;
using ESF.SFT.FileUploader.Presenter.General;

#endregion


namespace ESF.SFT.FileUploader
{
	/// <summary>
	/// Interaction logic for InternetConnectionOptions.xaml
	/// </summary>
	public partial class InternetConnectionOptions : BaseWPFWindow, IInternetConnectionOptionsViewer
	{
		#region Members

		InternetConnectionOptionsPresenter _Presenter;

		#endregion


		#region Constructor

		public InternetConnectionOptions()
			: base()
		{
			InitializeComponent();

			try
			{
				imgIcon.Source = WinFormsHelper.ToBitmapSource(SharedImages.NetworkConnections_64x64);

				Icon = WinFormsHelper.ToBitmapSource(SharedImages.Upload_64x64);
			}
			catch (Exception pEx)
			{
				Log.Error (pEx);
			}

			txtProxyUserLogin.Focus ();


			_Presenter = new InternetConnectionOptionsPresenter (this);

			_Presenter.Load ();

			IncludeVersionInTitle();
		}

		#endregion


		#region Button Events

		private void btnDefineProxySettings_Click(object sender, RoutedEventArgs e)
		{
			if (_Presenter.TryConnect ())
			{
				Hide ();
			}
		}

		#endregion


		#region Window Events

		private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
		{
			CloseApplication ();
		}

		#endregion


		#region IInternetConnectionOptions Fields

		public string ProxyUserLogin { get { return txtProxyUserLogin.Text; } }

		public string ProxyUserPassword { get { return txtProxyUserPassword.Password; } }

		public string ProxyAddress { set { txtProxyAddress.Text = value; } get { return txtProxyAddress.Text; } }

		public string ProxyPortNumber { set { txtProxyPortNumber.Text = value; } get { return txtProxyPortNumber.Text; } }

		#endregion
	}
}
